package m202405.d13;

/**
 * @@author: 爱做梦的锤子
 * @date: 2024/5/13 12:28
 */
public class Q104 {

    private int maxDepth = 0;

    public int maxDepth(TreeNode root) {
        travel(root, 0);
        return maxDepth;
    }

    public void travel(TreeNode node, int depth) {
        if (node == null) {
            maxDepth = Math.max(depth, maxDepth);
            return;
        }
        travel(node.left, depth + 1);
        travel(node.right, depth + 1);
    }
}
